const webpack = require("webpack");
console.log(process.env.VUE_APP_BASE_API);
module.exports = {
    // 屏幕适配处理
    css: {
        loaderOptions: {
            css: {
                // options here will be passed to css-loader
            },
            postcss: {
                // options here will be passed to postcss-loader
                plugins: [
                    require("postcss-px2rem")({
                        remUnit: 10, //设计稿的尺寸是750px 就需要除2，这里是375px
                    }),
                ],
            },
        },
    },

    lintOnSave: process.env.NODE_ENV !== "production",
    devServer: {
        disableHostCheck: true,
        port: 9520,
        open: false, // 启动打开浏览器
        compress: true, // 开启压缩
        // https: true,
        overlay: {
            warnings: false,
            errors: true,
        },
        proxy: {
            "/api/addressBook": {
                // target: `${process.env.VUE_APP_BASE_API}:47791`, //接口域名
                target: `${process.env.VUE_APP_BASE_API}:9081`, //接口域名
                changeOrigin: true, //是否跨域
                ws: true, //是否代理 websockets
                // secure: true, //是否https接口
                pathRewrite: {
                    //路径重置
                    "^/api/addressBook": "/api/addressBook",
                },
            },
            "/api/worker": {
                target: `${process.env.VUE_APP_BASE_API}:9082`, //接口域名
                changeOrigin: true, //是否跨域
                ws: true, //是否代理 websockets
                // secure: true, //是否https接口
                pathRewrite: {
                    //路径重置
                    "^/api/worker": "/api/worker",
                },
            },
            "/api/expert": {
                target: `${process.env.VUE_APP_BASE_API}:9083`, //接口域名
                changeOrigin: true, //是否跨域
                ws: true, //是否代理 websockets
                // secure: true, //是否https接口
                pathRewrite: {
                    //路径重置
                    "^/api/expert": "/api/expert",
                },
            },
            "/api/orchard": {
                target: `${process.env.VUE_APP_BASE_API}:9085`, //接口域名
                changeOrigin: true, //是否跨域
                ws: true, //是否代理 websockets
                // secure: true, //是否https接口
                pathRewrite: {
                    //路径重置
                    "^/api/orchard": "/api/orchard",
                },
            },
            "/api/equip": {
                // target: `${process.env.VUE_APP_BASE_API}`, //接口域名
                target: `${process.env.VUE_APP_BASE_API}:9086`, //接口域名
                changeOrigin: true, //是否跨域
                ws: true, //是否代理 websockets
                // secure: true, //是否https接口
                pathRewrite: {
                    //路径重置
                    "^/api/equip": "/api/equip",
                },
            },
        },
    },
    chainWebpack: (config) => {
        // 设置项目title
        config.plugin("html").tap((args) => {
            args[0].title = "数字果园";
            return args;
        });
    },
    configureWebpack: {
        plugins: [
            new webpack.ProvidePlugin({
                $: "jquery",
                jQuery: "jquery",
                "windows.jQuery": "jquery",
            }),
        ],
    },
};
